import React, { Component } from "react";

export default function CheckLogin(Com){
    return class extends Component{
        UNSAFE_componentWillMount(){
            const token = localStorage.getItem('token')
            if(!token) {
                // 跳转到login
                this.props.history.push('/login')
                // 提示
                this.props.error('没有登录')
            }
        }
        render(){
            return <Com success={this.props.success} error={this.props.error}/>
        }
    }
}
